package com.salesys.gr.gui;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.SWT;
import com.salesys.gr.util.FrmHelper;
import com.salesys.gr.util.LoginedUserHelper;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.events.TraverseListener;
import org.eclipse.swt.events.TraverseEvent;

public class FrmViewInfo {

	protected Shell FrmViewInfo;

	/**
	 * Open the window.
	 * 
	 * @wbp.parser.entryPoint
	 */
	public void open() {
		Display display = Display.getDefault();
		createContents();
		FrmViewInfo.open();
		FrmViewInfo.layout();
		while (!FrmViewInfo.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
	}

	/**
	 * Create contents of the window.
	 */
	protected void createContents() {
		FrmViewInfo = new Shell(SWT.CLOSE | SWT.APPLICATION_MODAL);
		FrmViewInfo.addTraverseListener(new TraverseListener() {
			public void keyTraversed(TraverseEvent e) {
				if (e.keyCode == 27) {
					FrmViewInfo.close();
				}
			}
		});
		FrmViewInfo.setMinimumSize(new Point(132, 38));
		FrmViewInfo.setSize(270, 220);
		FrmViewInfo.setText("查看个人资料");
		// 窗口居中
		FrmViewInfo.setLocation(new FrmHelper().setLocationCenter(FrmViewInfo));

		Label lblUserName = new Label(FrmViewInfo, SWT.NONE);
		lblUserName.setBounds(18, 20, 61, 17);
		lblUserName.setText("用户名：");

		Label lblMemberId = new Label(FrmViewInfo, SWT.NONE);
		lblMemberId.setBounds(18, 76, 61, 17);
		lblMemberId.setText("加盟卡号：");

		Label lblNickName = new Label(FrmViewInfo, SWT.NONE);
		lblNickName.setBounds(18, 48, 61, 17);
		lblNickName.setText("姓　名：");

		Label lblQQ = new Label(FrmViewInfo, SWT.NONE);
		lblQQ.setBounds(18, 160, 61, 17);
		lblQQ.setText("QQ：");

		Label lblEmail = new Label(FrmViewInfo, SWT.NONE);
		lblEmail.setBounds(18, 132, 61, 17);
		lblEmail.setText("邮　箱：");

		Label lblBankcard = new Label(FrmViewInfo, SWT.NONE);
		lblBankcard.setBounds(18, 104, 61, 17);
		lblBankcard.setText("银行账号：");

		LoginedUserHelper.fresh();

		Label lblViewUserName = new Label(FrmViewInfo, SWT.NONE);
		lblViewUserName.setBounds(80, 20, 165, 17);
		// 获取用户名
		if (LoginedUserHelper.getLoginedUserUsername() != null) {
			lblViewUserName.setText(LoginedUserHelper.getLoginedUserUsername());
		} else {
			lblViewUserName.setText("");
		}

		Label lblViewMemberId = new Label(FrmViewInfo, SWT.NONE);
		lblViewMemberId.setBounds(80, 76, 165, 17);
		// 获取会员卡号
		if (LoginedUserHelper.getLoginedUserMemberId() != null) {
			lblViewMemberId.setText(LoginedUserHelper.getLoginedUserMemberId());
		} else {
			lblViewMemberId.setText("非正式会员没有会员卡号");
		}

		Label lblViewNickName = new Label(FrmViewInfo, SWT.NONE);
		lblViewNickName.setBounds(80, 48, 165, 17);
		// 获取昵称
		if (LoginedUserHelper.getLoginedUserNickname() != null) {
			lblViewNickName.setText(LoginedUserHelper.getLoginedUserNickname());
		} else {
			lblViewNickName.setText("");
		}

		Label lblViewQQ = new Label(FrmViewInfo, SWT.NONE);
		lblViewQQ.setBounds(80, 160, 165, 17);
		// 获取QQ号
		if (LoginedUserHelper.getLoginedUserQq() != null) {
			lblViewQQ.setText(LoginedUserHelper.getLoginedUserQq());
		} else {
			lblViewQQ.setText("");
		}

		Label lblViewEmail = new Label(FrmViewInfo, SWT.NONE);
		// 获取邮箱
		lblViewEmail.setBounds(80, 132, 165, 17);
		if (LoginedUserHelper.getLoginedUserEmail() != null) {
			lblViewEmail.setText(LoginedUserHelper.getLoginedUserEmail());
		} else {
			lblViewEmail.setText("");
		}

		Label lblViewBankcard = new Label(FrmViewInfo, SWT.NONE);
		// 获取银行账号
		lblViewBankcard.setBounds(80, 104, 165, 17);
		if (LoginedUserHelper.getLoginedUserBankcard() != null) {
			lblViewBankcard.setText(LoginedUserHelper.getLoginedUserBankcard());
		} else {
			lblViewBankcard.setText("");
		}
	}
}
